//package com.b2c.oms.controller;
//
//import com.b2c.common.api.ApiResult;
//import com.b2c.common.api.ApiResultEnum;
//import com.b2c.common.third.thymeleaf.PagingResponse;
//import com.b2c.common.utils.DateUtil;
//import com.b2c.common.utils.HttpImageUtil;
//import com.b2c.entity.OrderItemEntity;
//import com.b2c.entity.UserEntity;
//import com.b2c.entity.datacenter.DcAliOrderListVo;
//import com.b2c.entity.datacenter.vo.OfflineOrderListVo;
//import com.b2c.entity.enums.OrderTypeEnums;
//import com.b2c.entity.result.ResultVo;
//import com.b2c.entity.vo.OrderVo;
//import com.b2c.oms.DataConfigObject;
//import com.b2c.oms.request.OrderConfirmReq;
//import com.b2c.service.mall.UserService;
//import com.b2c.service.oms.OrderYungouService;
//import com.b2c.service.oms.ShopService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Controller;
//import org.springframework.ui.Model;
//import org.springframework.util.StringUtils;
//import org.springframework.web.bind.annotation.*;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.swing.*;
//import java.io.FileNotFoundException;
//import java.io.IOException;
//import java.io.OutputStream;
//import java.util.List;
//
///**
// * 描述：
// *
// * @author qlp
// * @date 2019-09-24 16:05
// */
//@RequestMapping("/order_yungou")
//@Controller
//public class YGOrderController {
//    @Autowired
//    private ShopService shopService;
//    @Autowired
//    private OrderYungouService orderYungouService;
//    @Autowired
//    private UserService userService;
//
//    /**
//     * 订单列表
//     *
//     * @param model
//     * @param request
//     * @return
//     */
//    @RequestMapping(value = "/list", method = RequestMethod.GET)
//    public String orderList(Model model, @RequestParam Integer shopId, HttpServletRequest request) {
//        //订单类型参数
//        OrderTypeEnums orderTypeEnums = OrderTypeEnums.PT;
//
//        if (shopId.intValue() == 3) {
//            orderTypeEnums = OrderTypeEnums.PT;
//        } else if (shopId.intValue() == 4) {
//            orderTypeEnums = OrderTypeEnums.PiFa;
//
//        } else if (shopId.intValue() == 11) {
//            orderTypeEnums = OrderTypeEnums.DaiFa;
//        }
//
//        //查询店铺信息
//        var shop = shopService.getShop(shopId);
//        model.addAttribute("shop", shop);
//        model.addAttribute("shopName", shop.getName());
//        model.addAttribute("menuId", "order_list");
//
//
//        String page = request.getParameter("page");
//        Integer pageIndex = 1;
//        Integer pageSize = DataConfigObject.getInstance().getPageSize();
//        String orderNum = "";
//        String mjMobile = "";
//        Integer startTime = 0;
//        Integer endTime = 0;
//        String salesmanMobile = "";
////        String developerMobile = "";
//        Integer state = -1;
//
//        if (!StringUtils.isEmpty(request.getParameter("status"))) {
//            state = Integer.parseInt(request.getParameter("status"));
//        }
//        if (!StringUtils.isEmpty(page)) {
//            pageIndex = Integer.parseInt(page);
//        }
//        if (!StringUtils.isEmpty(request.getParameter("pageSize"))) {
//            try {
//                pageSize = Integer.parseInt(request.getParameter("pageSize"));
//            } catch (Exception e) {
//            }
//        }
//        if (!StringUtils.isEmpty(request.getParameter("orderNum"))) {
//            orderNum = request.getParameter("orderNum");
//        }
//        if (!StringUtils.isEmpty(request.getParameter("mjMobile"))) {
//            mjMobile = request.getParameter("mjMobile");
//        }
//        if (!StringUtils.isEmpty(request.getParameter("startTime"))) {
//            startTime = DateUtil.dateToStamp(request.getParameter("startTime"));
//        }
//        if (!StringUtils.isEmpty(request.getParameter("endTime"))) {
//            endTime = DateUtil.dateTimeToStamp(request.getParameter("endTime") + " 23:59:59");
//        }
////        if (!StringUtils.isEmpty(request.getParameter("goodsName"))) {
////            goodsName = request.getParameter("goodsName");
////        }
//        if (!StringUtils.isEmpty(request.getParameter("salesmanMobile"))) {
//            salesmanMobile = request.getParameter("salesmanMobile");
//        }
//
//        Integer developerId = 0;
//        if (!StringUtils.isEmpty(request.getParameter("developerId"))) {
//            developerId = Integer.parseInt(request.getParameter("developerId"));
//        }
//        model.addAttribute("developerId", developerId);
////        if (!StringUtils.isEmpty(request.getParameter("developerMobile"))) {
////            developerMobile = request.getParameter("developerMobile");
////        }
//        model.addAttribute("pageIndex", pageIndex);
//        model.addAttribute("pageSize", pageSize);
//        PagingResponse<OrderVo> result = orderYungouService.getOrders(pageIndex, pageSize, orderNum, mjMobile, startTime, endTime, salesmanMobile, developerId, state, orderTypeEnums);
//        model.addAttribute("totalSize", result.getTotalSize());
//        model.addAttribute("lists", result.getList());
//
//        //查询业务员
//        List<UserEntity> developerList = userService.getDeveloperList();
//        model.addAttribute("developerList", developerList);
//
//        return "v3/yg/order_list_yungou";
//    }
//
//    /**
//     * 订单详情
//     *
//     * @param model
//     * @param id      订单Id
//     * @param request
//     * @return
//     */
//    @RequestMapping(value = "/order_detail", method = RequestMethod.GET)
//    public String getOrderDetail(Model model, @RequestParam Long id, @RequestParam Integer shopId, HttpServletRequest request) {
//        OfflineOrderListVo orderDetail = orderYungouService.getOrderDetail(id);
//
////        if (orderDetail.getType().intValue() == OrderTypeEnums.PiFa.getIndex()) {
////            shopId = 4;
////        } else if (orderDetail.getType().intValue() == OrderTypeEnums.DaiFa.getIndex()) {
////            shopId = 11;
////        }
//        //查询店铺信息
//        var shop = shopService.getShop(shopId);
//        model.addAttribute("shop", shop);
//        model.addAttribute("shopName", shop.getName());
//        model.addAttribute("menuId", "order_list");
//
//
////        Integer state = dcOrderService.getOrderState(id);
//        model.addAttribute("order", orderDetail);
////        model.addAttribute("state", state);  //状态，数字
//
////        String param = "{\"com\":\"" + orderDetail.getSendCompany() + "\",\"num\":\"" + orderDetail.getSendCode() + "\",\"\":\"" + orderDetail.getConsigneeMobile() + "\"}";
////        String customer = "B420E04416B8E902204B30C368B409DB";
////        String key = "HemHbdOY1667";
////        String sign = Md5Util.MD5(param + key + customer);// MD5.encode(param+key+customer);
////        HashMap params = new HashMap();
////        params.put("param", param);
////        params.put("sign", sign);
////        params.put("customer", customer);
////        String resp;
////        List<LogisticsVo> data = null;
////        try {
////            resp = new HttpRequest().httpRequest("http://poll.kuaidi100.com/poll/query.do", params);
////            QueryResultVo queryResultVo = JSONObject.parseObject(resp, QueryResultVo.class);
////            data = queryResultVo.getData();
////        } catch (Exception e) {
////            e.printStackTrace();
////        }
////        model.addAttribute("data", data);
//        return "v3/yg/order_detail_yungou";
//    }
//
//
//    /**
//     * 订单确认
//     *
//     * @param model
//     * @param orderId
//     * @param request
//     * @return
//     */
//    @RequestMapping(value = "/order_confirm", method = RequestMethod.GET)
//    public String orderConfirmGet(Model model, @RequestParam Long orderId, HttpServletRequest request) {
//        OfflineOrderListVo order = orderYungouService.getOrderDetail(orderId);
//        if (order == null) {
//            model.addAttribute("error", "没有找到订单");
//            model.addAttribute("orderVo", new DcAliOrderListVo());
//
//        } else {
//            model.addAttribute("orderVo", order);
//        }
//
//        return "v3/yg/order_confirm_yungou";
//    }
//
//    /**
//     * 确认订单
//     *
//     * @param id
//     * @param req
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping(value = "/order_confirm_post", method = RequestMethod.POST)
//    public ApiResult<Integer> confirmOrderYg(@RequestBody OrderConfirmReq req) {
//        if (req.getOrderId() == null || req.getOrderId() <= 0)
//            return new ApiResult<>(ApiResultEnum.ParamsError.getIndex(), "参数错误，缺少orderId");
//        if (StringUtils.isEmpty(req.getReceiver()))
//            return new ApiResult<>(ApiResultEnum.ParamsError.getIndex(), "参数错误，缺少receiver");
//        if (StringUtils.isEmpty(req.getMobile()))
//            return new ApiResult<>(ApiResultEnum.ParamsError.getIndex(), "参数错误，缺少mobile");
//        if (StringUtils.isEmpty(req.getAddress()))
//            return new ApiResult<>(ApiResultEnum.ParamsError.getIndex(), "参数错误，缺少address");
//
//        ResultVo<Integer> result = orderYungouService.orderConfirmAndJoinDeliveryQueueForYunGou(req.getOrderId(), req.getReceiver(), req.getMobile(), req.getAddress(), req.getSellerMemo());
//        return new ApiResult<>(result.getCode(), result.getMsg());
//    }
//}